#include <iostream>
using namespace std;

/*
    【题目187】编写一个程序，要求输入N个学生数据，包括学号、姓名、成绩，输出这些学生数据并计算平均分。
*/

class Student
{
public:
    Student(int id, string name, double score)
    {
        this->id = id;
        this->name = name;
        this->score = score;
        number++;
        sum += score;
    }
    void show()
    {
        cout << "学号：" << id << endl;
        cout << "姓名：" << name << endl;
        cout << "成绩：" << score << endl;
    }
    double average()
    {
        cout << "平均成绩为：" << sum / number << endl;
        return sum / number;
    }

private:
    int id;
    string name;
    double score;
    static int number; // 学生人数
    static double sum; // 学生总分
};
int Student::number = 0;
double Student::sum = 0;
int main()
{
    int n;
    cout << "请输入学生人数：" << endl;
    cin >> n;
    // 创建学生对象数组
    Student *s[n];
    for (int i = 0; i < n; i++)
    {
        cout << "请输入第" << i + 1 << "个学生的信息(学号、姓名、成绩):" << endl;
        int id;
        string name;
        double score;
        cin >> id >> name >> score;
        s[i] = new Student(id, name, score);
    }
    for (int i = 0; i < n; i++)
    {
        cout << "第" << i + 1 << "个学生的信息为：" << endl;
        s[i]->show();
    }
    s[1]->average();
    

    return 0;
}